package com.caigou.comm.base.container

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.caigou.comm.base.utils.DialogUtil

/**
 * @author #Suyghur.
 * Created on 2021/09/13
 */
abstract class BaseFragment : Fragment() {
    private var isLoaded = false

    protected open val mDialog by lazy {
        DialogUtil.getLoadingDialog(requireActivity(), "")
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
        observeViewModel()
    }

    override fun onResume() {
        super.onResume()
        if (!isLoaded && !isHidden) {
            lazyLoad()
            isLoaded = true
        }
    }

    abstract fun initView()

    abstract fun lazyLoad()

    abstract fun onBack()

    open fun observeViewModel() {

    }


}